package com.example.messageservice.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class MessagePropertiesUtil implements InitializingBean {

    @Value("${aliyun.textmessage.file.keyid}")
    private String keyId;
    @Value("${aliyun.textmessage.file.keysecret}")
    private String keySecret;
    @Value("${aliyun.textmessage.file.signname}")
    private String signName;
    @Value("${aliyun.textmessage.file.templatecode}")
    private String templateCode;

    //定义公开静态常量
    public static String KEY_ID;
    public static String KEY_SECRET;
    public static String SIGN_NAME;
    public static String TEMPLATE_CODE;

    //项目一启动，private变量初始化成功后，下面的方法就会执行
    @Override
    public void afterPropertiesSet() throws Exception {
        KEY_ID = keyId;
        KEY_SECRET = keySecret;
        SIGN_NAME = signName;
        TEMPLATE_CODE = templateCode;
    }
}
